import random

def ifRight(list1,listNum):
    error = 0
    for i in range(len(list1)):
        if list1[i] != listNum[i]:
            error+=1
    if error == 0:
        return "中一等奖"
    elif error == 1:
        return "中二等奖"
    elif error == 2:
        return "中三等奖"
    elif error == 7:
        return "中四等奖"
    else:
        return "芜湖破产"
        
def buy(num):
    list1 = []
    for i in range(0,num):
        list1.insert(i,None)
    for i in range(0,num):
        list1[i] = random.sample(range(1,33),8)
    return list1
    
            
while True:
    list1 = [0,0,0,0,0,0,0,0]
    list1 = random.sample(range(1,33),8)
    print("\n开奖号码:",list1,'\n')

    yes = 0
    
    num = int(input('你打算随机买:'))
    listBuy = buy(num)
    for i in range(len(listBuy)):
        print(listBuy[i],'----->',ifRight(list1,listBuy[i]))
        if ifRight(list1,listBuy[i]) != "芜湖破产":
            yes+=1
            
    list2 = []
    for i in range(0,yes):
        list2.insert(i,None)
    
    if len(list2)!=0:
        for i in range(len(list2)):
            print(list2[i],'----->',ifRight(list1,list2[i]))
